package org.prosim.framework.action;

import java.io.IOException;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.jdom.JDOMException;
import org.prosim.action.BaseAction;
import org.prosim.framework.Menu;
import org.prosim.framework.service.FrameworkService;
import org.springframework.beans.factory.annotation.Autowired;


@SuppressWarnings("serial")
@Namespace("/framework")
@InterceptorRefs( { @InterceptorRef("paramsPrepareParamsStack") })
public class FrameworkAction extends BaseAction {
	@Autowired
	private FrameworkService frameworkService;
	

	@Action("/index")
	public String doIndex() throws Exception {
		return SUCCESS;
	}

	
	@Action("leftside")
	public String doLeftSide() throws JDOMException, IOException {
		List<Menu> menus = frameworkService.leftsideMenus();
		ctxAttribute("menus", menus);
		return SUCCESS;
	}
	
	
	@Action("graphs")
	public String doGraphs() {
		return SUCCESS;
	}
	
	@Action("contentbox1")
	public String doContentbox1() {
		return SUCCESS;
	}
	
	@Action("contentbox2")
	public String doContentbox2() {
		return SUCCESS;
	}
	
	@Action("contentbox3")
	public String doContentbox3() {
		return SUCCESS;		
	}
	
	@Action("contentbox4")
	public String doContentbox4() {
		return SUCCESS;
	}
	
	@Action("footer")
	public String doFooter() {
		return SUCCESS;
	}
	
	@Action(value = "showerror", results = { @Result(name = SUCCESS, location = "contentbox4.jsp") })
	public String doShowerror() {
		addErrorMessage("error infomation");
		return SUCCESS;
	}
	
	@Action(value = "showwarn", results = { @Result(name = SUCCESS, location = "contentbox3.jsp") })
	public String doShowwarn() {
		addWarnMessage("warn infomation");		
		return SUCCESS;
	}
	
	
	@Action(value = "showinfo", results = { @Result(name = SUCCESS, location = "contentbox1.jsp") })
	public String doShowinfo() {
		addMessage("info information");		
		return SUCCESS;
	}
	
	@Action(value = "showsuccess", results = { @Result(name = SUCCESS, location = "contentbox2.jsp") })
	public String doShowsuccess() {
		addSuccessMessage("success information");		
		return SUCCESS;
	}

}
